﻿#region << 文件说明 >>

/*----------------------------------------------------------------
 * 命名空间：Vampirewal.Core.Interface
 * 唯一标识：6dd947af-bb9a-46c6-90c6-00cb7205c675
 * 文件名：IVampirewalListDataSourceLoader
 *
 * 创建者：杨程
 * 电子邮箱：235160615@qq.com
 * 创建时间：2023/10/30 11:01:18
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/

#endregion << 文件说明 >>

namespace Vampirewal.Core.Interface;

/// <summary>
/// 列表数据加载器
/// </summary>
public interface IVampirewalListDataSource<TSource> where TSource : TopModel
{
}

/// <summary>
/// 高级搜索
/// </summary>
public interface IVampirewalAdvancedSearch
{
    /// <summary>
    /// 获取高级搜索的ViewKey
    /// </summary>
    string GetAdvancedSearchViewKey { get; }

    /// <summary>
    /// 显示高级搜索
    /// </summary>
    /// <returns></returns>
    void DisplayAdvancedSearch();
}

/// <summary>
/// 已选择器
/// </summary>
public interface IVampirewalSelectorLoader<TSource> : IVampirewalListDataSource<TSource> where TSource : TopModel
{
    /// <summary>
    /// 根据查询已选择项
    /// </summary>
    /// <param name="selectedIDs"></param>
    ListContainer<TSource> GetSelectedItemsByIDs(params string[] selectedIDs);
}

/// <summary>
/// 分页列表预览加载器
/// </summary>
/// <typeparam name="TSource"></typeparam>
public interface IVampirewalPreviewPageList<TSource> : IVampirewalListDataSource<TSource> where TSource : TopModel
{
    /// <summary>
    /// 获取分页列表数
    /// </summary>
    /// <param name="pageNum">翻页信息</param>
    /// <param name="searchText">文字搜索内容</param>
    /// <returns></returns>
    PageBaseModel<TSource> GetItemSource(PageNumberModel pageNum, string searchText) ;
}

/// <summary>
/// 全加载列表预览加载器
/// </summary>
/// <typeparam name="TSource"></typeparam>
public interface IVampirewalPreviewFullList<TSource> : IVampirewalListDataSource<TSource> where TSource : TopModel
{
    /// <summary>
    /// 获取列表数
    /// </summary>
    /// <param name="searchText">文字搜索内容</param>
    /// <returns></returns>
    ListContainer<TSource> GetItemSource(string searchText);
}

public class TestModel1234 : TopModel
{
}

public abstract class VampirewalPreviewFullListLoader<TSource> : IVampirewalPreviewFullList<TSource>, IVampirewalSelectorLoader<TSource>, IVampirewalAdvancedSearch where TSource : TopModel
{
    /// <summary>
    /// 是否显示新增按钮
    /// </summary>
    public bool IsShowAddBtn { get; set; } = true;

    /// <summary>
    /// 菜单ID
    /// </summary>
    public abstract string MenuID { get; set; }

    /// <summary>
    /// 执行新增
    /// </summary>
    public abstract void ExecuteAppendNewItem();

    /// <summary>
    /// 执行编辑项
    /// </summary>
    /// <param name="editObj">编辑项</param>
    public abstract void ExecuteEditItem(object editObj);

    /// <summary>
    /// 执行功能操作
    /// </summary>
    /// <param name="token">功能对应的标识</param>
    /// <param name="curRowData">当前行</param>
    public virtual void ExecuteOperator(string token, object curRowData)
    { }

    /// <inheritdoc />
    public abstract string GetAdvancedSearchViewKey { get; }

    /// <inheritdoc />
    public abstract ListContainer<TSource> GetItemSource(string searchText);

    /// <inheritdoc />
    public abstract ListContainer<TSource> GetSelectedItemsByIDs(params string[] selectedIDs);
    /// <inheritdoc />
    public abstract void DisplayAdvancedSearch();

    #region 顶部自定义按钮

    /// <summary>
    /// 顶部自定义按钮
    /// </summary>
    public ObservableCollection<EditButtonModel> CustomButtons { get; set; }

    #endregion
}

public abstract class VampirewalPreviewPageListLoader<TSource> : IVampirewalPreviewPageList<TSource>, IVampirewalSelectorLoader<TSource>, IVampirewalAdvancedSearch where TSource : TopModel
{
    /// <summary>
    /// 是否显示新增按钮
    /// </summary>
    public bool IsShowAddBtn { get; set; } = true;

    /// <summary>
    /// 菜单ID
    /// </summary>
    public abstract string MenuID { get; set; }

    /// <summary>
    /// 执行新增
    /// </summary>
    public abstract void ExecuteAppendNewItem();

    /// <summary>
    /// 执行编辑项
    /// </summary>
    /// <param name="editObj">编辑项</param>
    public abstract void ExecuteEditItem(object editObj);

    /// <summary>
    /// 执行功能操作
    /// </summary>
    /// <param name="token">功能对应的标识</param>
    /// <param name="curRowData">当前行</param>
    public virtual void ExecuteOperator(string token, object curRowData)
    { }

    /// <inheritdoc />
    public abstract string GetAdvancedSearchViewKey { get; }

    /// <inheritdoc />
    public abstract PageBaseModel<TSource> GetItemSource(PageNumberModel pageNum, string searchText) ;

    /// <inheritdoc />
    public abstract ListContainer<TSource> GetSelectedItemsByIDs(params string[] selectedIDs);

    /// <inheritdoc />
    public abstract void DisplayAdvancedSearch();
}

/// <summary>
/// 
/// </summary>
public class testaaa : VampirewalPreviewFullListLoader<TestModel1234>
{
    /// <inheritdoc />
    public override string GetAdvancedSearchViewKey { get; }
    /// <inheritdoc />
    public override string MenuID { get; set; }
    /// <inheritdoc />
    public override void DisplayAdvancedSearch()
    {

    }
    /// <inheritdoc />
    public override void ExecuteAppendNewItem()
    {
    }
    /// <inheritdoc />
    public override void ExecuteEditItem(object editObj)
    {
    }
    /// <inheritdoc />
    public override ListContainer<TestModel1234> GetItemSource(string searchText)
    {
        throw new NotImplementedException();
    }
    /// <inheritdoc />
    public override ListContainer<TestModel1234> GetSelectedItemsByIDs(params string[] selectedIDs)
    {
        throw new NotImplementedException();
    }
}